package com.zllkj.mm.adapter

import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zllkj.mm.R
import com.zllkj.mm.module.goods.vm.ItemPostImageVM
import com.zllkj.mm.widgets.RoundImageView

class PushPostAdapter(layoutResId: Int, data: List<ItemPostImageVM?>?) :
        BaseQuickAdapter<ItemPostImageVM, BaseViewHolder>(layoutResId, data) {
    override fun convert(baseViewHolder: BaseViewHolder, vm: ItemPostImageVM) {
         if (vm.isAddPosition) {
            baseViewHolder.getView<AppCompatImageView>(R.id.iv_post_image).setImageResource(R.mipmap.ic_add_pic)

            baseViewHolder.getView<AppCompatImageView>(R.id.iv_remove_image).visibility = View.GONE
             baseViewHolder.getView<AppCompatTextView>(R.id.tv_duration).visibility = View.GONE
             baseViewHolder.getView<AppCompatTextView>(R.id.tv_duration).text = vm.videoDuration
        } else {
            //PictureLoadUtil.loadPic(baseViewHolder.getView<AppCompatImageView>(R.id.iv_post_image),vm.filePicUrl)
            Glide.with(mContext).load(vm.path).into(baseViewHolder.getView<AppCompatImageView>(R.id.iv_post_image))
            baseViewHolder.getView<AppCompatImageView>(R.id.iv_remove_image).visibility = View.VISIBLE

            if (vm.itemType == 1) {
                baseViewHolder.getView<AppCompatTextView>(R.id.tv_duration).visibility = View.VISIBLE
                baseViewHolder.getView<AppCompatTextView>(R.id.tv_duration).text = vm.videoDuration
            } else {
                baseViewHolder.getView<AppCompatTextView>(R.id.tv_duration).visibility = View.GONE
                baseViewHolder.getView<AppCompatTextView>(R.id.tv_duration).text = vm.videoDuration
            }
        }
        baseViewHolder.addOnClickListener(R.id.iv_remove_image)
    }
}